package com.example.myapplication.module1.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
import com.example.myapplication.R
import com.example.myapplication.databinding.ItemBroadcastBinding
import com.example.myapplication.entity.BroadcastBean
import com.example.mylibrary.adapter.BaseRecyclerAdapter
import com.example.mylibrary.utils.UiTools

class BroadcastAdapter(context: Context) : BaseRecyclerAdapter<ItemBroadcastBinding>(context) {
    var broadcastBeans: MutableList<BroadcastBean> = mutableListOf()
        set(value) {
            field = value
            notifyDataSetChanged()
        }

    override fun getBinding(
        inflater: LayoutInflater,
        parent: ViewGroup,
        viewType: Int
    ): ItemBroadcastBinding {
        return ItemBroadcastBinding.inflate(inflater, parent, false)
    }

    override fun bindHolder(holder: BaseViewHolder, position: Int) {
        val broadcastBean = broadcastBeans[position]
        viewBinding.tvTitle.text = broadcastBean.title
        viewBinding.tvTime.text = "${UiTools.getString(R.string.publishTime)}${broadcastBean.opdate}"
    }

    override fun getItemCount(): Int {
        return broadcastBeans.size
    }

}
